﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Abp.Domain.Entities;
using FwProject.Comm.ExcelUtil;
using FwProject.Core.SettlementInfoModel;

namespace FwProject.Settlement.Dto
{
    /// <summary>
    /// 收款单
    /// </summary>
    [DisplayName(displayName: "收据查询")]
    public class SettlementReceivableDto : Entity<Guid>
    {
        /// <summary>
        /// 结账编号
        /// </summary>
        [Display(Name = "结账id")]
        public Guid SettlementId { get; set; }
        [Display(Name = "审核状态")]
        [DisplayName(displayName: "状态")]
        [ExcelDateMember]
        public ExamineStatus ExamineStatus { get; set; }
        [Display(Name = "商家是否确认")]
        [DisplayName(displayName: "商家是否确认")]
        [ExcelDateMember]
        public RestaurantPayStatus RestaurantPayStatus { get; set; } = RestaurantPayStatus.未收款;
        [Display(Name = "收款时间")]
        [DisplayName(displayName: "收款时间")]
        [ExcelDateMember]
        public DateTime CreationTime { get; set; }
        [Display(Name = "结账单号")]
        [DisplayName(displayName: "收款单号")]
        [ExcelDateMember]
        public string CreationNumber { get; set; }
        [Display(Name = "餐厅名称")]
        [DisplayName(displayName: "餐厅名称")]
        [ExcelDateMember]
        public string RestaurantName { get; set; }
        [Display(Name = "司机id")]
        public long? DriverId { get; set; }
        [Display(Name = "司机")]
        public string DriverName { get; set; }
        [Display(Name = "应收金额")]
        [DisplayName(displayName: "应收金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal TotalPrice { get; set; }
        [Display(Name = "制单优惠")]
        [DisplayName(displayName: "制单优惠")]
        [ExcelDateMember(IsSum = true)]
        public decimal Discountprice { get; set; }
        [Display(Name ="收款优惠")]
        [DisplayName(displayName: "收款优惠")]
        [ExcelDateMember(IsSum = true)]
        public decimal ReceivedDiscount { get; set; }

        [Display(Name = "实际金额")]
        [DisplayName(displayName: "实际金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal Actualprice { get; set; }

        [Display(Name = "未收金额")]
        [DisplayName(displayName: "未收金额")]
        [ExcelDateMember(IsSum = true)]
        public decimal UncollectedPrice { get; set; }
        /// <summary>
        /// 使用预收款
        /// </summary>
        [Display(Name = "使用预收款")]
        [DisplayName(displayName: "使用预收款")]
        [ExcelDateMember(IsSum = true)]
        public decimal UsePrePayment { get; set; }

        [Display(Name = "优惠率")]
        [DisplayName(displayName: "优惠率")]
        [ExcelDateMember]
        public string DiscountRate { get { return (Convert.ToDouble(Discountprice + ReceivedDiscount) / Convert.ToDouble(TotalPrice)).ToString("0.00%"); } }

        [Display(Name = "配送时间")]
        [DisplayName(displayName: "配送时间")]
        [ExcelDateMember]
        /// <summary>
        /// 配送时间 2018-01-01-2018--01-31 当月
        /// 2018-01-01 当日
        /// </summary>
        public string DeliveryDate { get; set; }

        public DateTime BeginTime { get; set; }

        public DateTime EndTime { get; set; }
        /// <summary>
        /// 默认定期结算特殊情况按照日结系统默认自动生成数据。
        /// </summary>
        [Display(Name = "结算方式")]
        [DisplayName(displayName: "结算方式")]
        [ExcelDateMember]
        public FwProject.Core.Restaurant.BalanceWayEnum BalanceWayEnum { get; set; } = FwProject.Core.Restaurant.BalanceWayEnum.定期结算;

        /// <summary>
        /// 收据备注
        /// </summary>
        [Display(Name = "备注")]
        [DisplayName(displayName: "备注")]
        [ExcelDateMember]
        public string RemarksConten { get; set; }

    }
}
